package Utils;

import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;

public class CookieUtils {
     public static String getCookie(Cookie[] cookies, String key)
    {
        for (Cookie cookie:cookies)
        {
            if (cookie.getName().equals(key))
                return cookie.getValue();
        }
        return null;
    }
    public static void deleteCookie(Cookie[] cookies, String key, HttpServletResponse response)
    {
        for (Cookie cookie:cookies)
        {
            if (cookie.getName().equals(key))
                cookie.setMaxAge(0);
                response.addCookie(cookie);
        }
    }
}
